package bairui.international.controller.ticket.offset;

/**
 * @see bairui.international.controller.ticket.offset.Page_BaseFilter
 *
 */
class Page_Filter

{
	
	/**
	 * 过滤扩展接口
	 */
	static interface FilterExtends {
		com.querydsl.core.types.Predicate gainRequestUser(
			String requestUser
		);
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_ElectronicTicketOrder QRoot,
		javax.servlet.http.HttpServletRequest request
		,FilterExtends filterExtends
	) {
		com.querydsl.core.BooleanBuilder query = query(
				QRoot
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("number"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("name"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("comment"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("price"), 
						Double.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("count"), 
						Long.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("type"), 
						bairui.international.model.type.Type_ElectronicTicket.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("oneuseFlag"), 
						Boolean.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("giveFlag"), 
						Boolean.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("state"), 
						bairui.international.model.status.State_ElectronicTicketOrder.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("expiryDate_start"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					),
				com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("expiryDate_end"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("applyDate_start"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					),
				com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("applyDate_end"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					)
			);
			/* comment 附加过滤属性 */
			if(null != request.getParameter("requestUser")){
				query.and(filterExtends.gainRequestUser(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("requestUser"), 
							String.class, 
							"yyyy-MM-dd"
						)
				));
			}
	;
		return query;
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_ElectronicTicketOrder QRoot
	,	String number
	,	String name
	,	String comment
	,	Double price
	,	Long count
	,	bairui.international.model.type.Type_ElectronicTicket type
	,	Boolean oneuseFlag
	,	Boolean giveFlag
	,	bairui.international.model.status.State_ElectronicTicketOrder state
	,	java.util.Date expiryDate_start,
		java.util.Date expiryDate_end
	,	java.util.Date applyDate_start,
		java.util.Date applyDate_end
	) {
		com.querydsl.core.BooleanBuilder builder = new com.querydsl.core.BooleanBuilder();
	
		if(null != number){
			builder.and(QRoot.number.like("%"+number+"%"));
		}
		if(null != name){
			builder.and(QRoot.name.like("%"+name+"%"));
		}
		if(null != comment){
			builder.and(QRoot.comment.like("%"+comment+"%"));
		}
		if(null != price){
			builder.and(QRoot.price.eq(price));
		}
		if(null != count){
			builder.and(QRoot.count.eq(count));
		}
		if(null != type){
			builder.and(QRoot.type.eq(type));
		}
		if(null != oneuseFlag){
			builder.and(QRoot.oneuseFlag.eq(oneuseFlag));
		}
		if(null != giveFlag){
			builder.and(QRoot.giveFlag.eq(giveFlag));
		}
		if(null != state){
			builder.and(QRoot.state.eq(state));
		}
		if(null != expiryDate_start && null != expiryDate_end){
			builder.and(QRoot.expiryDate.between(expiryDate_start, expiryDate_end));
		}
		if(null != applyDate_start && null != applyDate_end){
			builder.and(QRoot.applyDate.between(applyDate_start, applyDate_end));
		}
		return builder;
	}
	
}
